import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import { getHconfLisUrl, getDepartmentMyInfoUrl } from '../common/ajax';

export default new Vuex.Store({
  state: {
    hwConfig:{},
    tran_start_site: "",
    hwUserKs:[],
  },
  mutations:{
    setHwConfig(state,data){
      state.hwConfig = data
    },
    setHwUserKs(state,data){
      state.hwUserKs = data
    }
  },
  actions:{
    getWasteConfig({ commit }){
      jQuery.ajax({
        url: getHconfLisUrl,
        type: 'GET',
        success: function(data){
          if(data.success){
            commit("setHwConfig",data.data)
          }else {
            throwErrorTips(data.msg)
          }
        }.bind(this),
        error: function(err){
          throwErrorTips("网络超时")
        }
      })
    },
    getWasteUserKs({commit}){
      jQuery.ajax({
        url: getDepartmentMyInfoUrl,
        type: 'GET',
        success: function(data){
          if(data.success){
            commit("setHwUserKs",data.data)
          }else {
            throwErrorTips(data.msg)
          }
        }.bind(this),
        error: function(err){
          throwErrorTips("网络超时")
        }
      })
    }
    
  }
})